<?php

class Database {
	public $connection; //The MySQL Database connection
	
    function Database() {
    	$this->connection = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error());
    	mysql_select_db(DB_NAME, $this->connection) or die(mysql_error());
    }
    
    /**
     * getItem - get Item data from database.
     */
    function getItem($id) {
    	$q = "SELECT * FROM ".TBL_ITEMS." WHERE ".ITEM_ID."='$id'";
    	$result = $this->query($q);
    	return mysql_fetch_array($result);
    }
    
    /**
     * query - execute database query
     */
	function query($q) {
     	return mysql_query($q, $this->connection);
	}
}

$database = new Database();
?>